﻿<ResourceDictionary x:Class="Hopscotch.Presentation.Controls.Resources.ModuleResources"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:cmnCnvrtrs="clr-namespace:Hopscotch.Presentation.Common.Converters;assembly=Hopscotch.Presentation.Common">

    <!--Styles-->
    <Style x:Key="ControlErrorToolTipStyle" TargetType="{x:Type FrameworkElement}">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip">
                    <Setter.Value>
                        <MultiBinding Converter="{cmnCnvrtrs:ValidationErrorsToStringConverter}">
                            <Binding Path="(Validation.Errors)" RelativeSource="{x:Static RelativeSource.Self}"/>
                            <Binding Path="(Validation.Errors).Count" RelativeSource="{x:Static RelativeSource.Self}"/>
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--Converters-->
    <cmnCnvrtrs:DataErrorInfoToImageConverter x:Key="ErrorIconConverter">
        <cmnCnvrtrs:DataErrorInfoToImageConverter.ErrorIcon>pack://application:,,,/Hopscotch.Presentation.Controls;component/Images/error16.png</cmnCnvrtrs:DataErrorInfoToImageConverter.ErrorIcon>
        <cmnCnvrtrs:DataErrorInfoToImageConverter.WarningIcon>pack://application:,,,/Hopscotch.Presentation.Controls;component/Images/warning16.png</cmnCnvrtrs:DataErrorInfoToImageConverter.WarningIcon>
        <cmnCnvrtrs:DataErrorInfoToImageConverter.InfoIcon>pack://application:,,,/Hopscotch.Presentation.Controls;component/Images/info16.png</cmnCnvrtrs:DataErrorInfoToImageConverter.InfoIcon>
    </cmnCnvrtrs:DataErrorInfoToImageConverter>
    <cmnCnvrtrs:DatabindingDebugConverter x:Key="debugConverter" />

    <!--Control Templates-->
    <ControlTemplate x:Key="ErrorContentControl" TargetType="ContentControl">            
        <Border BorderBrush="{Binding Path=Content.BorderBrush, ElementName=wrappedElement}" 
                BorderThickness="1"
                Padding="0 0 0 0" Margin="0 0 0 0">
            <DockPanel LastChildFill="True">
                <Image
                        DockPanel.Dock="Left"
                        Source="{Binding ElementName=wrappedElement, Path=Content.(Validation.Errors).CurrentItem.ErrorContent, Converter={StaticResource ResourceKey=ErrorIconConverter}}"
                        Margin="0 0 0 0"
                    
                        VerticalAlignment="Center"
                        Height="12"
                        Stretch="Uniform">

                    <Image.ToolTip>
                        <MultiBinding Converter="{cmnCnvrtrs:ValidationErrorsToStringConverter}">
                            <Binding Path="Content.(Validation.Errors)" ElementName="wrappedElement"/>
                            <Binding Path="Content.(Validation.Errors).Count" ElementName="wrappedElement"/>
                        </MultiBinding>
                    </Image.ToolTip>
                </Image>

                <!--Wrapped Element/Content Presenter-->
                <ContentPresenter x:Name="wrappedElement"/>

            </DockPanel>
        </Border>

    </ControlTemplate>

</ResourceDictionary>
